package org.ipp4j.core.standard;

public enum Version {

	V1_1(0x0101), V1_0(0x01000), V2_0(0x0200), V2_1(0x0201);

	int code;

	byte[] bytes;

	Version(int code) {
		this.code = code;
		this.bytes = new byte[] { (byte) (this.code >>> 8), (byte) (this.code) };
	}

	public static Version valueOf(short code) {
		for (Version version : Version.values()) {
			if (version.code == code) {
				return version;
			}
		}
		throw new IllegalArgumentException("version code " + code
				+ " cannot be found.");
	}

	public byte[] toByteArray() {
		return bytes;
	}
}
